package com.ddx.common.enums;

import java.math.BigDecimal;

/**
 * @author junqiang.wang
 * @ClassName ResultType
 * @Description BannerType
 * @Company: www.eloancn.com
 * @date 2016/9/21 15:08
 */

public enum AwardRule {

    BTCFIRST(new BigDecimal("0.01"),new BigDecimal("0.1"),new BigDecimal("0.2"),new BigDecimal("0.1"), CurrencyType.BTC.getCode(),"BTC第一阶梯"),
    BTCONE(new BigDecimal("0.1"),new BigDecimal("1"),new BigDecimal("0.5"),new BigDecimal("0.25"), CurrencyType.BTC.getCode(),"BTC第二阶梯"),
    BTCTWO(new BigDecimal("1"),new BigDecimal("2"),new BigDecimal("0.8"),new BigDecimal("0.4"), CurrencyType.BTC.getCode(),"BTC第三阶梯"),
    BTCTHREE(new BigDecimal("2"),new BigDecimal("5"),new BigDecimal("1"),new BigDecimal("0.5"), CurrencyType.BTC.getCode(),"BTC第四阶梯"),
    BTCFOUR(new BigDecimal("5"),new BigDecimal(Integer.MAX_VALUE),new BigDecimal("1.5"),new BigDecimal("0.75"), CurrencyType.BTC.getCode(),"BTC第五阶梯"),
    ETHFIRST(new BigDecimal("0.1"),new BigDecimal("1"),new BigDecimal("0.2"),new BigDecimal("0.1"), CurrencyType.ETH.getCode(),"ETH第一阶梯"),
    ETHONE(new BigDecimal("1"),new BigDecimal("10"),new BigDecimal("0.5"),new BigDecimal("0.25"), CurrencyType.ETH.getCode(),"ETH第二阶梯"),
    ETHTWO(new BigDecimal("10"),new BigDecimal("20"),new BigDecimal("0.8"),new BigDecimal("0.4"), CurrencyType.ETH.getCode(),"ETH第三阶梯"),
    ETHTHREE(new BigDecimal("20"),new BigDecimal("50"),new BigDecimal("1"),new BigDecimal("0.5"), CurrencyType.ETH.getCode(),"ETH第四阶梯"),
    ETHFOUR(new BigDecimal("50"),new BigDecimal(Integer.MAX_VALUE),new BigDecimal("1.5"),new BigDecimal("0.75"), CurrencyType.ETH.getCode(),"ETH第五阶梯");
    private BigDecimal minAmount;
    private BigDecimal maxAmount;
    private BigDecimal oneRate;
    private BigDecimal twoRate;
    private Integer currencyType;
    private String msg;

    AwardRule(BigDecimal minAmount, BigDecimal maxAmount, BigDecimal oneRate, BigDecimal twoRate, Integer currencyType, String msg) {
        this.minAmount=minAmount;
        this.maxAmount=maxAmount;
        this.oneRate=oneRate;
        this.twoRate=twoRate;
        this.currencyType=currencyType;
        this.msg=msg;
    }

    public BigDecimal getMinAmount() {
        return minAmount;
    }

    public void setMinAmount(BigDecimal minAmount) {
        this.minAmount = minAmount;
    }

    public BigDecimal getMaxAmount() {
        return maxAmount;
    }

    public void setMaxAmount(BigDecimal maxAmount) {
        this.maxAmount = maxAmount;
    }

    public BigDecimal getOneRate() {
        return oneRate;
    }

    public void setOneRate(BigDecimal oneRate) {
        this.oneRate = oneRate;
    }

    public BigDecimal getTwoRate() {
        return twoRate;
    }

    public void setTwoRate(BigDecimal twoRate) {
        this.twoRate = twoRate;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static AwardRule getRate(BigDecimal amount, Integer currencyType) {
        for (AwardRule t : AwardRule.values()) {
            if(currencyType.equals(t.currencyType)&&amount.compareTo(t.getMinAmount())>=0&&amount.compareTo(t.getMaxAmount())<0){
                return t;
            }
        }
        return null;
    }
}
